﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class WorkflowDefCls
    {
        public string WorkflowDefId;
        public string WorkFlowName;
        public string XmlData;
    }

    public class WorkflowDefParser
    {
        public static WorkflowDefCls CreateInstance()
        {
            //tao 1 class trang....
            WorkflowDefCls oWorkflowDefCls = new WorkflowDefCls();
            return oWorkflowDefCls;
        }

        public static WorkflowDefCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            WorkflowDefCls oWorkflowDefCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oWorkflowDefCls;
        }


        public static WorkflowDefCls ParseFromDataRow(DataRow dr)
        {
            WorkflowDefCls OWorkflowDefCls = new WorkflowDefCls();
            OWorkflowDefCls.WorkflowDefId = (string)dr["WorkflowDefId"];
            OWorkflowDefCls.WorkFlowName = (string)dr["WorkFlowName"];
            OWorkflowDefCls.XmlData = (string)dr["XmlData"];
            return OWorkflowDefCls;
        }

        public static WorkflowDefCls[] ParseFromDataTable(DataTable dtTable)
        {
            WorkflowDefCls[] WorkflowDefs = new WorkflowDefCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                WorkflowDefs[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return WorkflowDefs;
        }
    }
}


